package com.zh.controller;

import com.zh.SnowflakeIdGenerator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class IdController {

    private final SnowflakeIdGenerator idGenerator;

    public IdController(SnowflakeIdGenerator idGenerator) {
        this.idGenerator = idGenerator;
    }

    @GetMapping("/idGenerate")
    public Map<String, Object> generate() {
        long id = idGenerator.nextId();
        return Map.of("code", 1, "msg", "", "data", String.valueOf(id));
    }
}

